#include "FuncPane.h"
#include "GLWidget.h"
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
#include <QObject>
#include <QPushButton>
#include <QScreen>
#include <QVBoxLayout>
#include <QWidget>

void prepare()
{

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
	QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
	QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
	QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif

#ifdef _DEBUG
	qSetMessagePattern("%{file}:%{line} - %{message}");
#endif
}

int main(int argc, char* argv[])
{
	prepare();

	QApplication a(argc, argv);

	QWidget mainWidget;
	auto	rect = a.primaryScreen()->availableGeometry();
	qDebug() << "primaryScreen rect-width " << rect.width();
	qDebug() << "primaryScreen rect-height " << rect.height();
	rect.setHeight(rect.height() - 60);

	mainWidget.setGeometry(rect);

	auto mainLayout = new QHBoxLayout(&mainWidget);
	mainLayout->setContentsMargins(0, 0, 0, 0);
	mainLayout->setSpacing(0);

	auto* glWidget = new GLWidget(&mainWidget);
	qDebug() << "main-glWidget:" << glWidget;
	mainLayout->addWidget(glWidget);

	auto* funcPane = new FuncPane(&mainWidget, glWidget);
	funcPane->setFixedWidth(140);
	mainLayout->addWidget(funcPane);

	qWarning() << "devicePixelRatio " << a.devicePixelRatio();
	qWarning() << "availableGeometry" << a.primaryScreen()->availableGeometry();
	qWarning() << "mainWidget.size" << mainWidget.size();

	qDebug() << "before mainWidget.show();";
	mainWidget.show();

	qDebug() << "after mainWidget.show();";

	return a.exec();
}
